home *** CD-ROM | disk | FTP | other *** search
/ Robotics & Artificial Int…3 (Professional Edition) / Robotics & Artificial Intelligence Tools 2003 (Professional Edition).iso / neural network tool and application / nsinstall.exe / data1.cab / Demos_Files / DLL / MOMENTUM.C < prev    next >
Encoding:
C/C++ Source or Header  |  2002-03-08  |  1.4 KB  |  45 lines

  1. // Dynamic link library implementation of NeuroSolutions Momentum component 
  2.  
  3. #include "NSDLL.h" 
  4.  
  5. /*****************************/
  6. /* Gradient search procedure */
  7.  
  8. __declspec(dllexport) void performMomentum(
  9.     DLLData    *instance,    // Pointer to instance data (may be NULL)
  10.     NSFloat    *weights,    // Pointer to the vector of weights
  11.     int    length,        // Length of the weight vector
  12.     NSFloat    *gradient,    // Pointer to the vector of gradients, one for each weight
  13.     NSFloat    *step,        // Pointer to the learning rate/s
  14.     BOOL    individual,    // Indicates whether their is one learning rate for all weights (FALSE),
  15.                 // or each weight has its own learning rate
  16.     NSFloat    momentum,    // Momentum rate for all weights
  17.     NSFloat    *delta        // Last weight Update
  18.     )
  19. {
  20.     register int i;
  21.  
  22.     for (i=0; i<length; i++)
  23.         weights[i] += delta[i] = momentum*delta[i] + step[individual?i:0]*gradient[i];
  24. }
  25.  
  26. /******************************************/
  27. /* Management of instance data (OPTIONAL) */
  28. /*
  29. __declspec(dllexport) DLLData *allocMomentum(
  30.     DLLData    *oldInstance,    // Pointer to the last instance if reallocating
  31.     int    length,        // Length of the weight vector
  32.     BOOL    individual    // Indicates whether their is one learning rate for all weights (FALSE),
  33.                 // or each weight has its own learning rate
  34.     )
  35. {
  36.     DLLData *instance = allocDLLInstance(oldInstance);
  37.     return instance;
  38. }
  39.  
  40. __declspec(dllexport) void freeMomentum(DLLData *instance)
  41. {
  42.     freeDLLInstance(instance);
  43. }
  44. */
  45.